Skip to content

加密模型包到内存 - YoloEncryptModelEx

函数简介

加密并输出整包到内存。

接口名称

YoloEncryptModelEx

DLL 调用

int YoloEncryptModelEx(long ola, long modelData, int modelSize, long ncnnParamData, int ncnnParamSize, long labelData, int labelSize, string password, int modelType, int inferenceType, long* outPackageData, long* outPackageSize);

参数说明

参数名类型说明
ola长整数型OLAPlug 对象指针,由 CreateCOLAPlugInterFace 生成。
modelData长整数型主模型地址。
modelSize整数型主模型长度。
ncnnParamData长整数型NCNN param 地址。
ncnnParamSize整数型param 长度。
labelData长整数型类别名称表内存地址;无则 0。原始字节,编码见 类别名称表说明
labelSize整数型类别名称表字节长度;无则 0。
password字符串密码。
modelType整数型模型类型。
inferenceType整数型推理类型。
outPackageData长整数型*输出:整包地址。
outPackageSize长整数型*输出:包总长度。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value");
csharp
using OLAPlug;

var ola = new OLAPlugServer();
int ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value");
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value")
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
int ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value");
cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value")
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value")
text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.YoloEncryptModelEx(0, 0, “models/yolov8n.olam”, “models/yolov8n.olam”, 0, 0, “your_password”, 0, 0, “value”, “value”)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value");
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value")
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int32_t ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value");

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
YoloEncryptModelEx(instance, 0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, 0, 0);
csharp
using System.Runtime.InteropServices;
using System.Text;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int YoloEncryptModelEx(long ola, long modelData, int modelSize, long ncnnParamData, int ncnnParamSize, long labelData, int labelSize, string password, int modelType, int inferenceType, long outPackageData, long outPackageSize);

long instance = CreateCOLAPlugInterFace();
YoloEncryptModelEx(instance, 0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, 0, 0);
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ola.YoloEncryptModelEx(instance, 0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, 0, 0)

返回值

返回值说明
1成功。
0失败。

注意事项

项目说明
模块权限需要插件已开通 YOLO 模块权限(Reg、Login的FeatureList中包含YOLO特性)。
包内 names 归一化为 UTF-8 存储包内 names 归一化为 UTF-8 存储;labelData 编码规则见 类别名称表说明
释放内存插件分配的内存须调用 FreeMemoryPtr 释放。